{template 'header'}
<link rel="stylesheet" href="{$siteRoot}addons/{$modular_name}/template/kindeditor/themes/default/default.css" />
<link rel="stylesheet" href="{$siteRoot}addons/{$modular_name}/template/kindeditor/plugins/code/prettify.css" />
<script charset="utf-8" src="{$siteRoot}addons/{$modular_name}/template/kindeditor/kindeditor-all.js"></script>
<script charset="utf-8" src="{$siteRoot}addons/{$modular_name}/template/kindeditor/lang/zh-CN.js"></script>
<script charset="utf-8" src="{$siteRoot}addons/{$modular_name}/template/kindeditor/plugins/code/prettify.js"></script>
<ul class="nav nav-tabs">
    <li class="active"><a href="{php echo $this->createWeburl('luck');}">抽奖管理</a></li>
    <li class=""><a href="{php echo $this->createWeburl('luck', array('op' => 'addShow'));}">添加抽奖</a></li>
</ul>
<form action="" method="post" class="form-horizontal" id="myform" role="form" enctype="multipart/form-data">
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">奖品名称:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="name" placeholder="奖品名称" value="{$luck['name']}" {if $id} disabled {/if} type="text">
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">奖品数量:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="number" placeholder="奖品数量" value="{$luck['number']}"  {if $id} disabled {/if} type="text">
        </div>
    </div>
    <div class="form-group" id="ling-1">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">奖品图片:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            {php echo tpl_form_field_image('image',  $luck['image'],  tomedia($luck['image']));}
            <small style="color: red">图片大小建议为 : 60 * 60 正方形即可</small>
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">开奖方式</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio-inline">
                <input type="radio" name="lottery_type" value="1" {if $luck['lottery_type'] == 1 || $luck['lottery_type'] == ''} checked {/if} /> 时间自动开奖
            </label>
            <label class="radio-inline">
                <input type="radio" name="lottery_type" value="2" {if $luck['lottery_type'] == 2} checked {/if}/>人数开奖
            </label>
          <!--  <label class="radio-inline">
                <input type="radio" name="lottery_type" value="3" {if $luck['lottery_type'] == 3} checked {/if}/>手动开奖
            </label>

            <label class="radio-inline">
                <input type="radio" name="lottery_type" value="4" {if $luck['lottery_type'] == 4} checked {/if}/>现场抽奖
            </label>-->
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">是否需要观看视频广告</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio-inline">
                <input type="radio" name="is_ad" value="1" {if $luck['is_ad'] == 1 || $luck['is_ad'] == ''} checked {/if} /> 不需要
            </label>
            <label class="radio-inline">
                <input type="radio" name="is_ad" value="2" {if $luck['is_ad'] == 2} checked {/if}/>需要
            </label>

        </div>
    </div>
    <div class="form-group" id="luckTime"  {if in_array($luck['lottery_type'], array(2,3,4))} style="display: none"  {/if}>
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">开奖时间:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            {php echo tpl_form_field_date('lottery_value', $luck['lottery_value'], true)}
        </div>
    </div>
    <div class="form-group" id="luckNumber" {if $luck['lottery_type'] !=2} style="display: none"  {/if}>
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">开奖人数:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="lottery_value_s" placeholder="开奖人数" value="{$luck['lottery_value']}" type="text">
        </div>
    </div>



    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">抽奖方式</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio-inline">
                <input type="radio" name="luck_mode" value="1" {if $luck['luck_mode'] == 1 || $luck['luck_mode'] == ''} checked {/if} /> 普通抽奖
            </label>
            <label class="radio-inline">
                <input type="radio" name="luck_mode" value="2" {if $luck['luck_mode'] == 2} checked {/if}/>组队抽奖
            </label>
            <label class="radio-inline">
                <input type="radio" name="luck_mode" value="3" {if $luck['luck_mode'] == 3} checked {/if}/>好友助力
            </label>
            <label class="radio-inline">
                <input type="radio" name="luck_mode" value="4" {if $luck['luck_mode'] == 4} checked {/if}/>口令抽奖
            </label>
        </div>
    </div>

    <div class="form-group" id="team_number"  {if $luck['luck_mode'] !=2} style="display: none"  {/if}>
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">组队人数:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="team_number" placeholder="组队人数" value="{$luck['team_number']}" type="text">
        </div>
    </div>

    <div class="form-group" id="luck_pwd" {if $luck['lottery_type'] !=4} style="display: none"  {/if}>
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">口令抽奖:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="luck_pwd" placeholder="口令抽奖" value="{$luck['luck_pwd']}" type="text">
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">抽奖说明:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">

            <textarea name="lottery_explain" cols="145" rows="10">{$luck['lottery_explain']}</textarea>
        </div>
    </div>
    <div class="form-group" id="compiler" >
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">抽奖详情:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12" style="padding-top:8px;">
            <textarea name="image_text" style="width:1100px;height:400px;visibility:hidden;">{$luck['image_text']}</textarea>
        </div>
        <script>
            KindEditor.ready(function(K) {
                htmlEditor = K.create(
                    'textarea[name="image_text"]',
                    {
                        uploadJson : "{php echo $this->createWebUrl('editorUpload');}",
                        fileManagerJson : '{$siteRoot}addons/{$modular_name}/template/kindeditor/php/file_manager_json.php',
                        height : 300,
                        width : '100%',
                        resizeType : 0,//1
                        allowPreviewEmoticons : true,
                        allowImageUpload : true,
                        urlType:'domain',
                        formatUploadUrl:false
                    });
            });
        </script>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">赞助商:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="sponsor" placeholder="赞助商" value="{$luck['sponsor']}" type="text">
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">赞助类型</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio-inline">
                <input type="radio" name="sponsor_type" value="1" {if $luck['sponsor_type'] == 1 || $luck['sponsor_type'] == ''} checked {/if} /> 仅显示
            </label>
            <label class="radio-inline">
                <input type="radio" name="sponsor_type" value="2" {if $luck['sponsor_type'] == 2} checked {/if}/>小程序
            </label>
            <label class="radio-inline">
                <input type="radio" name="sponsor_type" value="3" {if $luck['sponsor_type'] == 3} checked {/if}/>公众号
            </label>
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">自动开启下一期</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio-inline">
                <input type="radio" name="loop" value="1" {if $luck['loop'] == 1 || $luck['loop'] == ''} checked {/if} /> 结束后不自动生成
            </label>
            <label class="radio-inline">
                <input type="radio" name="loop" value="2" {if $luck['loop'] == 2} checked {/if}/>结束后自动生成相同抽奖
            </label>

        </div>
    </div>
    <div class="form-group"  id="sponsor_text" {if in_array($luck['sponsor_type'], array(2, 3))} style="display: none" {/if}>
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">赞助内容:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="sponsor_text" placeholder="赞助内容" value="{$luck['sponsor_text']}" type="text">
        </div>
    </div>
    <div id="sponsor_applet" {if $luck['sponsor_type'] !=2} style="display: none"{/if}>
         <div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-1 control-label">赞助类型</label>
            <div class="col-sm-9 col-xs-12">
                <label class="radio-inline">
                    <input type="radio" name="type_type" value="1" {if $luck['type_type'] == 1 || $luck['type_type'] == ''} checked {/if} /> 图片
                </label>
                <label class="radio-inline">
                    <input type="radio" name="type_type" value="2" {if $luck['type_type'] == 2} checked {/if}/>小程序信息
                </label>
            </div>
        </div>
         <div class="form-group" id="applet_images" {if in_array($luck['type'], array(2))} style="display: none" {/if}>
            <label class="col-xs-12 col-sm-3 col-md-1 control-label">小程序图片:</label>
            <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
                {php echo tpl_form_field_image('sponsor_image',  $luck['sponsor_image'],  tomedia($luck['sponsor_image']));}
                <small style="color: red">图片大小建议为 : 300*350 正方形即可</small>
            </div>
        </div>

        <div id="applet_text" {if $luck['type_type'] != 2} style="display: none" {/if} >
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-1 control-label">小程序appId:</label>
                <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
                    <input class="form-control" name="appid" placeholder="小程序appId" value="{$luck['appid']}" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-1 control-label">小程序路径:</label>
                <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
                    <input class="form-control" name="path" placeholder="小程序路径" value="{$luck['path']}" type="text">
                </div>
            </div>
        </div>

    </div>
    <div class="form-group" id="sponsor_bjnews" {if $luck['sponsor_type'] != 3} style="display: none"  {/if} >
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">公众号账号:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="sponsor_text_c" placeholder="公众号账号" value="{$luck['sponsor_text']}" type="text">
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label"></label>
        <div class="" >
            <input type="hidden" name="op" value="{php echo $id ? 'edit' : 'add'}">
            <input type="hidden" name="id" value="{$id}">
            {if $id}
            <input type="hidden" name="name" value="{$luck['name']}">
            <input type="hidden" name="number" value="{$luck['number']}">
            {/if}
            <input type="submit" name="submit" id="submit" value="{php echo $id ? '修改' : '新增'}" class="btn btn-primary">
        </div>
    </div>
</form>
{template 'footer'}


<script>
    $(function () {
        $("input[name='lottery_type']").click(function () {
            if ( $(this).val() ==1) {
                $('#luckTime').show();
                $('#luckNumber').hide();
            } else if ($(this).val() == 2 ) {
                $('#luckTime').hide();
                $('#luckNumber').show();
            } else {
                $('#appId').show();
            }
        });



        $("input[name='luck_mode']").click(function () {
            if ( $(this).val() ==2) {
                $('#team_number').show();
                $('#luck_pwd').hide();
            } else if ($(this).val() == 4 ) {
                $('#team_number').hide();
                $('#luck_pwd').show();
            } else {
                $('#team_number').hide();
                $('#appId').show();
            }
        });
        $("input[name='type_type']").click(function () {
            if ( $(this).val() ==1) {
                $('#applet_images').show();
                $('#applet_text').hide();
            } else{
                $('#applet_images').hide();
                $('#applet_text').show();
            }
        });

        $("input[name='sponsor_type']").click(function () {
            if ( $(this).val() ==1) {
                $('#sponsor_text').show();
                $('#sponsor_bjnews').hide();
                $('#sponsor_applet').hide();
            } else if ($(this).val() == 2){
                $('#sponsor_text').hide();
                $('#sponsor_bjnews').hide();
                $('#sponsor_applet').show();
            } else  {
                $('#sponsor_text').hide();
                $('#sponsor_bjnews').show();
                $('#sponsor_applet').hide();
            }
        });

    })


</script>